﻿#ifndef CANTHREAD_H
#define CANTHREAD_H

#include <QObject>
#include <QLibrary>
#include <QTimer>
#include <mutex>

class CanThread : public QObject
{
    Q_OBJECT

public:
    CanThread(QObject *parent = nullptr);
    ~CanThread();

    static CanThread* Instance();

    bool isLoad();
    bool isOpen();
    bool isConnect();

public slots:
    void SlotCanConnect(unsigned long, unsigned long);
    void SlotCanStop();
    void SlotCanStart();
    void SlotCanRestart();
    void SlotTimer();

private:
    unsigned long devtype = 0;//设备类型号
    unsigned long devindex = 0;//设备索引号

    bool m_isOpen = false;
    bool m_isConnect = false;
    bool m_isLoad = false;

    QLibrary *pCanLib;
    QTimer *pTimer;
    QThread *pThread;

    std::mutex mMutex;
};

#endif // CANTHREAD_H
